package servlet;

import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/ServletDemo5")
public class ServletDemo5 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String s ="3 2 1 我不见了，打不着我------------";
        //设置编码格式
        resp.setContentType("text/html;charset=UTF-8");
        //写出数据
        PrintWriter writer = resp.getWriter();
        writer.write(s);
        //定时刷新   注意要写虚拟路径
        resp.setHeader("Refresh","3;URL=https://www.baidu.com/?tn=44004473_24_oem_dg");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}

